# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItem do
  @moduledoc """
  ProductCatalogItem captures item metadata specific to retail products.

  ## Attributes

  *   `availableQuantity` (*type:* `String.t`, *default:* `nil`) - Optional. The available quantity of the item.
  *   `canonicalProductUri` (*type:* `String.t`, *default:* `nil`) - Optional. Canonical URL directly linking to the item detail page with a length limit of 5 KiB..
  *   `costs` (*type:* `map()`, *default:* `nil`) - Optional. A map to pass the costs associated with the product. For example: {"manufacturing": 45.5} The profit of selling this item is computed like so: * If 'exactPrice' is provided, profit = displayPrice - sum(costs) * If 'priceRange' is provided, profit = minPrice - sum(costs)
  *   `currencyCode` (*type:* `String.t`, *default:* `nil`) - Optional. Only required if the price is set. Currency code for price/costs. Use three-character ISO-4217 code.
  *   `exactPrice` (*type:* `GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice.t`, *default:* `nil`) - Optional. The exact product price.
  *   `images` (*type:* `list(GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1Image.t)`, *default:* `nil`) - Optional. Product images for the catalog item.
  *   `priceRange` (*type:* `GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange.t`, *default:* `nil`) - Optional. The product price range.
  *   `stockState` (*type:* `String.t`, *default:* `nil`) - Optional. Online stock state of the catalog item. Default is `IN_STOCK`.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :availableQuantity => String.t() | nil,
          :canonicalProductUri => String.t() | nil,
          :costs => map() | nil,
          :currencyCode => String.t() | nil,
          :exactPrice =>
            GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice.t()
            | nil,
          :images =>
            list(
              GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1Image.t()
            )
            | nil,
          :priceRange =>
            GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange.t()
            | nil,
          :stockState => String.t() | nil
        }

  field(:availableQuantity)
  field(:canonicalProductUri)
  field(:costs, type: :map)
  field(:currencyCode)

  field(:exactPrice,
    as:
      GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemExactPrice
  )

  field(:images,
    as: GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1Image,
    type: :list
  )

  field(:priceRange,
    as:
      GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItemPriceRange
  )

  field(:stockState)
end

defimpl Poison.Decoder,
  for:
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItem do
  def decode(value, options) do
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItem.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for:
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductCatalogItem do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
